package com.youle.mapper;

import com.youle.item.pojo.Brand;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * Created by
 *
 * @author touni
 * @date 2019/4/18
 * @time 18:53
 */
@Component
public interface BrandMapper extends Mapper<Brand> {

    //插入到中间表categorybrand中
    @Insert("INSERT INTO tb_category_brand (category_id, brand_id) VALUES (#{cid},#{id})")
    int insertIntoCategoryBrand( Long cid,Long id);

    @Select("SELECT category_id FROM tb_category_brand WHERE brand_id =#{bid}")
    List<Long> selectCategoryIdByBid(Long bid);



    @Delete("DELETE FROM tb_category_brand WHERE brand_id=#{bid}")
    int deleteCategoryBrand(Long bid);

    /*@Select("SELECT * FROM tb_brand WHERE `name` LIKE '%#{key}%' OR letter LIKE '%#{key}%'")
    List<Brand> selectByKey(String key);*/
}
